package com.ww.sound_emission.controller;

import com.ww.sound_emission.domain.Photographers;
import com.ww.sound_emission.service.PhotographersService;
import com.ww.sound_emission.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/photographers")
public class PhotographerController {

    @Autowired
    private PhotographersService photographerService;

    // 获取所有摄影师
    @GetMapping
    public Result<List<Photographers>> getAllPhotographers() {
        List<Photographers> photographers = photographerService.list();
        return Result.success(photographers);
    }

    // 添加摄影师
    @PostMapping
    public Result<String> addPhotographer(@RequestBody Photographers photographer) {
        photographerService.save(photographer);
        return Result.success("摄影师添加成功");
    }

    // 删除摄影师
    @DeleteMapping("/{id}")
    public Result<String> deletePhotographer(@PathVariable Long id) {
        photographerService.removeById(id);
        return Result.success("摄影师删除成功");
    }
}